document.addEventListener('DOMContentLoaded', function() {
    const brightnessSlider = document.getElementById('brightness');
    const colorTempSlider = document.getElementById('colorTemp');
    const fullscreenIcon = document.getElementById('fullscreen-icon');

    function updateBackground() {
        const brightness = brightnessSlider.value;
        const colorTemp = colorTempSlider.value;

        // 根据色温计算颜色
        const red = Math.min(255, 255 * (colorTemp / 100));
        const blue = Math.min(255, 255 * ((100 - colorTemp) / 100));
        const green = 200; // 为简单起见，绿色保持不变

        document.body.style.backgroundColor = `rgb(${red}, ${green}, ${blue})`;
        document.body.style.filter = `brightness(${brightness}%)`;
    }

    function toggleFullscreen() {
        if (!document.fullscreenElement) {
            document.documentElement.requestFullscreen().catch(err => {
                alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
            });
        } else {
            document.exitFullscreen();
        }
    }

    brightnessSlider.addEventListener('input', updateBackground);
    colorTempSlider.addEventListener('input', updateBackground);
    fullscreenIcon.addEventListener('click', toggleFullscreen);

    // 初始化背景
    updateBackground();
}); 